package yawning.mew.cat;

import yawning.mew.sim.SimulationAction;
import yawning.mew.sim.SimulationEventAction;

public class EventTigersFury extends SimulationEventAction {
	private CatModelSimState mState;
	public double mCooldownAt;
	
	EventTigersFury(CatModelSimState state) {
		super(state.mSimUtil);
		mState = state;
	}

	@Override
	public double perform() {
		if (isUp() || mCooldownAt > mState.mSimUtil.getSimTime() || mState.berserkEv.isUp()) return SimulationAction.ACTION_FAIL;

		if (mState.mDebug) mState.DBGF("Tiger's Fury");

		mState.nrTF++;

		mState.tigersFuryEv.schedule(mState.mModel.tigersFuryBuffDuration);
		if (mState.mModel.kotjEnergyGain > 0) mState.energyTickEv.mEnergy = Math.min(mState.energyTickEv.mEnergyCap, mState.energyTickEv.mEnergy + mState.mModel.kotjEnergyGain);
		mCooldownAt = mState.mSimUtil.getSimTime() + mState.mModel.tigersFuryCDDuration;
		mState.onPrimalMadnessGain();
		return 0.0f;
	}

	@Override
	public void onExpire() {
		if (mState.mDebug) mState.DBGF("Tiger's Fury Expiration");
		mState.onPrimalMadnessLoss();
	}
}